import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { ElectronService } from '../core/services';

@Component({
  selector: 'app-home',
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.scss']
})
export class HomeComponent implements OnInit {

  constructor(private router: Router,
    private electronservice:ElectronService) { 

      this.electronservice.ipcRenderer.on("asynchronous-reply",(event, arg) => {
        console.dir(event);
        console.log("主线成消息"+arg) // prints "pong"
      })


      this.electronservice.ipcRenderer.on('asynchronous-reply', (event, arg) => {
        console.log(arg) // prints "pong"
      })

    }

  ngOnInit(): void { }



  send(){
    console.log('实践触发');
    //console.dir(this.electronservice);
    // this.electronservice.ipcRenderer.sendSync("asynchronous-message","异步消息");
    //console.log("从主线返回的值"+retvalue);
    // var value=this.electronservice.ipcRenderer.send("synchronous-message","同步消息");
  
    //  console.log(value);


    // var revalue= this.electronservice.ipcRenderer.emit("synchronous-message","同步消息");
    // console.log(revalue);

    this.electronservice.ipcRenderer.invoke('some-name', "发送参数").then((result) => {
      // ...
      console.dir(result);
    })


  }

}
